package com.google.code.mircle.core.player;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

import com.google.code.mircle.App;
import com.google.code.mircle.core.Model;
import com.google.code.mircle.core.Plugin;
import com.google.code.mircle.core.Root;
import com.google.code.mircle.core.View;

public class PlayerPlugin implements Plugin, Model, Root {

    PlayerView view;
    App app;

    public PlayerPlugin(App app) {
        this.app = app;
        view = new PlayerView(app, this);
    }

    public void close() {

    }

    public String getName() {
        return "Player";
    }

    public Model[] getModels() {
        return null;
    }

    public JPopupMenu contextMenu(Model m) {
        JPopupMenu popup = new JPopupMenu();
        JMenuItem mm = new JMenuItem("123");
        mm.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
            }
        });
        popup.add(mm);
        return popup;
    }

    public View createView(Model m) {
        if (m instanceof PlayerPlugin)
            return view;
        return null;
    }

    public void play(File file) {
        app.modelSwitch(getClass());
        view.play(file);
    }

    @Override
    public void save(File path) {
        // TODO Auto-generated method stub

    }

    @Override
    public void load(File path) {
        // TODO Auto-generated method stub

    }

}
